package com.analyse.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.analyse.common.annotation.Log;
import com.analyse.common.core.controller.BaseController;
import com.analyse.common.core.domain.AjaxResult;
import com.analyse.common.enums.BusinessType;
import com.analyse.system.domain.Weibtopic;
import com.analyse.system.service.IWeibtopicService;
import com.analyse.common.utils.poi.ExcelUtil;
import com.analyse.common.core.page.TableDataInfo;

/**
 * 热点关键词TOPICController
 * 
 * @author analyse
 * @date 2023-05-09
 */
@RestController
@RequestMapping("/system/weibtopic")
public class WeibtopicController extends BaseController
{
    @Autowired
    private IWeibtopicService weibtopicService;

    /**
     * 查询热点关键词TOPIC列表
     */
    @PreAuthorize("@ss.hasPermi('system:weibtopic:list')")
    @GetMapping("/list")
    public TableDataInfo list(Weibtopic weibtopic)
    {
        startPage();
        List<Weibtopic> list = weibtopicService.selectWeibtopicList(weibtopic);
        return getDataTable(list);
    }


    @GetMapping("/listmax")
    public TableDataInfo listmax(Weibtopic weibtopic)
    {
        startPage();
        List<Weibtopic> list = weibtopicService.selectWeibtopicList(weibtopic);
        return getDataTable(list);
    }
    /**
     * 导出热点关键词TOPIC列表
     */
    @PreAuthorize("@ss.hasPermi('system:weibtopic:export')")
    @Log(title = "热点关键词TOPIC", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Weibtopic weibtopic)
    {
        List<Weibtopic> list = weibtopicService.selectWeibtopicList(weibtopic);
        ExcelUtil<Weibtopic> util = new ExcelUtil<Weibtopic>(Weibtopic.class);
        util.exportExcel(response, list, "热点关键词TOPIC数据");
    }

    /**
     * 获取热点关键词TOPIC详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:weibtopic:query')")
    @GetMapping(value = "/{topic}")
    public AjaxResult getInfo(@PathVariable("topic") String topic)
    {
        return success(weibtopicService.selectWeibtopicByTopic(topic));
    }

    /**
     * 新增热点关键词TOPIC
     */
    @PreAuthorize("@ss.hasPermi('system:weibtopic:add')")
    @Log(title = "热点关键词TOPIC", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Weibtopic weibtopic)
    {
        return toAjax(weibtopicService.insertWeibtopic(weibtopic));
    }

    /**
     * 修改热点关键词TOPIC
     */
    @PreAuthorize("@ss.hasPermi('system:weibtopic:edit')")
    @Log(title = "热点关键词TOPIC", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Weibtopic weibtopic)
    {
        return toAjax(weibtopicService.updateWeibtopic(weibtopic));
    }

    /**
     * 删除热点关键词TOPIC
     */
    @PreAuthorize("@ss.hasPermi('system:weibtopic:remove')")
    @Log(title = "热点关键词TOPIC", businessType = BusinessType.DELETE)
	@DeleteMapping("/{topics}")
    public AjaxResult remove(@PathVariable String[] topics)
    {
        return toAjax(weibtopicService.deleteWeibtopicByTopics(topics));
    }
}
